<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>Arvato企业微信后台管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../static/css/font.css">
		<link rel="stylesheet" href="../../static/css/weadmin.css">
		<link rel="stylesheet" href="../../static/css/font-awesome-4.7.0/css/font-awesome.min.css">
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
		<style>
			select {
				width: 150px;
				color: #666;
				height: 38px;
				line-height: 1.3;
				border: 1px solid #e6e6e6;
				background-color: #fff;
				border-radius: 2px;
				padding-left: 5px;
			}
		</style>
	</head>

	<body>
		<div class="weadmin-nav">
			<span class="layui-breadcrumb">
	        <a href="">权限管理</a>
	        <a>
	          <cite>免检列表</cite></a>
        	</span>
			<a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
				<i class="layui-icon" style="line-height:30px">ဂ</i>
			</a>
		</div>
		<div class="weadmin-body">
			<div class="weadmin-block">
				<button class="layui-btn" onclick="WeAdminShow('增加用户','./pass-add.html')"><i class="layui-icon"></i>增加</button>
				<span class="fr" style="line-height:40px"></span>
			</div>
			<!--  用户表格 -->
			<table class="layui-table" lay-filter="pass_table" id="pass_table" style="margin: 0"></table>
		</div>
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<script src="../../static/js/admin.js" charset="utf-8"></script>
		<script src="../../publicjs/jquery-1.8.0.min.js" charset="utf-8"></script>
		<script src="../../publicjs/smallkingutil.js" charset="utf-8"></script>
		<script>
			layui.use(['table'], function() {
				var table = layui.table;
				// 加载用户数据表格
				window.passTable = table.render({
					id: 'passTable',
					elem: '#pass_table',
					url: commonUtil.domain() + '/admin/right/pass/list', //数据接口
					method: 'post',
					page: true, //开启分页
					request: {
						pageName: 'pageNum', // 分页当前页数发给后台的参数名
						limitName: 'pageSize', // 分页每页多少条发给后台的参数名
						countName: 'total'
					},
					done: function(res) {
						$('.layui-laypage-count').text('共' + res.total + '条')
					},
					cols: [
						[ //表头
							{
								field: 'note',
								title: '描述',
								width: 150
							}, {
								field: 'url',
								title: 'URL',
								width: 280
							}, {
								field: 'oper',
								title: '操作',
								width: 60,
								templet: '#oper'
							}
						]
					]
				});
				// 刷新表格
				passTable.refresh = function(data) {
					passTable.reload({
						where: data,
						page: {
							curr: 1 // 重新从第 1 页开始
						}
					});
				}
			
				// 同步按钮
				window.sync = function(res) {
					layer.confirm('刷新客户的昵称，头像等信息', function(index) {
						var ajaxParam = {
								url : commonUtil.domain() + '/admin/right/pass/sync'
							}
						ajaxUtil.post(ajaxParam, function(data) {
							if (data.code == 200) {
								layer.alert("刷新成功");
								passTable.refresh();
							} else {
								layer.alert(data.msg);
							}
						});
					});
				}
				// 监听表格点击删除和修改按钮
				table.on('tool(pass_table)', function(obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
					var data = obj.data; // 获得当前行数据
					var id = data.id;
					var note = data.note;
					var layEvent = obj.event; // 获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
					var tr = obj.tr; // 获得当前行 tr 的DOM对象
					if(layEvent == "delete"){
						layer.confirm('确定删除' + note + '吗?', function(res){
							// 发送ajax解绑
							var ajaxParam = {
									url : commonUtil.domain() + '/admin/right/pass/delete',
									data : {
										id: id
									}
								}
							ajaxUtil.post(ajaxParam, function(data) {
								if (data.code == 200) {
									layer.alert("删除成功", {
										icon : 6
									}, function() {
										passTable.refresh();
										layer.closeAll();
									});
								} else {
									layer.alert(data.msg);
								}
							});
						});
					}
				});
			});
		</script>
	
		<script type="text/html" id="oper">
			<a title="删除" lay-event="delete"><i class="layui-icon">&#xe640;</i></a>
		</script>
	</body>

</html>